package cn.xutongxue.gtms.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.xutongxue.gtms.base.Errors;
import cn.xutongxue.gtms.base.Result;
import cn.xutongxue.gtms.entity.User;
import cn.xutongxue.gtms.entity.dto.MenuListVo;
import cn.xutongxue.gtms.exception.ThrowUtils;
import cn.xutongxue.gtms.service.impl.MenuServiceImpl;
import cn.xutongxue.gtms.service.impl.UserServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/menu")
@CrossOrigin
public class MenuController {

    @Resource
    private MenuServiceImpl menuService;

    @GetMapping("/getMenuList")
    @SaCheckLogin
    public Result getMenuList(@RequestParam("role") String role) {
        ThrowUtils.throwIf(role == null, Errors.PARAMS_ERROR);
        List<MenuListVo> menuListVos = menuService.getMenuList(role);
        return Result.success(menuListVos);
    }
}
